# coding:utf-8


from sql_rice.dbinspect import sqlite
import sqlite3 as dbapi
from sql_rice import serialization
import json


def inspect_db(database):
    connection = dbapi.connect(database)
    return sqlite.inspect(connection)


def main(db, outfile):
    with open(outfile, 'w') as out:
        dd = inspect_db(db)
        json.dump(dd, out, default=serialization.to_json, indent=2)


if __name__ == '__main__':
    import plac
    plac.call(main)
